<?php
	//引入配置文件和数据库操作函数
	require '../../public/config.php';
	require '../../public/mysql.php';
	require '../../public/function.php';
	//连接数据库
	$link = connect();
	//数据库查询商品信息的数据
		if ($link['error']) {
			$sql = "select * from detail";
//		echo $sql;
			$result = query($link['mess'], $sql);
		}
		$order=$result;
//        var_dump($order);



	//需要生成一个查询的条件
	$where='';
	$where1='';
	if (!empty($_GET['orderid'])) {
		$search=$_GET['orderid'];
		$where.= " and orderid like '%{$search}%'";
		$where1.= " and g.orderid like '%{$search}%'";
	}


//	分页
	$page = empty($_GET['p']) ? 1 :$_GET['p'];

	//设置每页显示几条数据
	$num = 5;
	//查询数据的总条数
	$sql = "select count(*) total from detail where 1 $where";
	$result = query($link['mess'], $sql);
	$totalNum = $result[0]['total'];

	//计算总页数
	$totalPage = ceil($totalNum / $num);

	//判断页面是否合法
	if ($page < 1) {
		$page = 1;
	}
	if ($page > $totalPage) {
		$page =  $totalPage;
	}
	
	//计算出起始位置
	$start = ($page - 1) * $num;
	//计算出起始位置
	$start = ($page - 1) * $num;
	//查询用户信息
	//准备sql语句
	$sql="select * from detail";

	$detail=query($link['mess'],$sql);
	

		
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>s54管理中心 - 商品列表 </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../include/Css/general.css" rel="stylesheet" type="text/css" />
<link href="../include/Css/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>
    <span class="action-span"><a href="./goodsAdd.php">添加新商品</a></span>
    <span class="action-span1"><a href="__GROUP__">ECSHOP 管理中心</a></span>
    <span id="search_id" class="action-span1"> - 商品列表 </span>
    <div style="clear:both"></div>
</h1>
<div class="form-div">
    <form action="./orderList.php" name="searchForm" method='get'>
        <img src="../include/Images/icon_search.gif" width="26" height="22" border="0" alt="search" />
		<!--发货状态-->
	
        <!-- 订单号搜索 -->
         订单号： <input type="text" name="keyword" size="15" />
        <input type="submit" value=" 搜索 " class="button" />
    </form>
</div>

<!-- 商品列表 -->

    <div class="list-div" id="listDiv">
        <table cellpadding="3" cellspacing="1">
            <tr>
				<th>订单号</th>
                <th>收货人</th>
                <th>商品名称</th>
                <th>商品价格</th>
                <th>商品数量</th>
                <th>用户ID</th>
            </tr>
		
			<?php if (!empty($order)) :?>
            <?php foreach ($order as $val) :?>
				<tr>
					<td align='center'><?php echo $val['orderid']?></td>	
					<td align='center'><?php echo $val['name']?></td>
					<td align='center'><?php echo $val['Commodity']?></td>
					<td align='center'><?php echo $val['price']?></td>
					<td align='center'><?php echo $val['num']?></td>
					<td align='center'><?php echo $val['uid']?></td>
				</tr>
            <?php endforeach;?>
			<?php else:?>
			<tr>
				<td colspan="9">暂无信息</td>
			</tr>
			<?php endif;?>
        </table>
		<!-- 分页开始 -->
		 <table id="page-table" cellspacing="0">
            <tr>
                <td width="80%">&nbsp;</td>
                <td align="center" nowrap="true">
				   <span>共<?php echo $totalPage?>页</span>
				   <span>第<?php echo $page?>/<?php echo $totalPage?>页</span>
                    <a href="orderList.php?p=1">首页</a>
					<a href="orderList.php?p=<?php echo $page - 1?>">上一页</a>
					<a href="orderList.php?p=<?php echo $page + 1?>">下一页</a>
					<a href="orderList.php?p=<?php echo $totalPage?>">尾页</a>
                </td>
            </tr>
        </table>
		<!-- 分页结束 -->
    </div>
<div id="footer">
共执行 7 个查询，用时 0.028849 秒，Gzip 已禁用，内存占用 3.219 MB<br />
版权所有 &copy; 2005-2012 暴走少年哈尔，并保留所有权利。</div>
</body>
</html>